<?php
session_start();
require '../nette/Nette/loader.php';
require '../db.php';
require '../localization/lang.php';
require '../core/core.sanitizer.php';
require '../core/core.security.php';
require '../core/core.time.php';
require '../core/core.attendance.php';

$login=new core_security;
if ($login->checklogin()=="OK") {

$date=new core_time;
$timestamp=mktime(00, 00, 00, $_POST['month'],$_POST['id'], $_POST['year']);
//$timestamp=strtotime($_POST['month']."-".$_POST['id']."-".$_POST['year']." 00:00:00");


$queryX="select * from attendance where uid=".$_SESSION['uid']." and day=".$timestamp."";
$result=mysql_query($queryX);
$row=mysql_fetch_array($result);
if (isset($row['att'])) {
	$query="update attendance set att=".$date->tosec($_POST['value'])." where uid=".$_SESSION['uid']." and day=".$timestamp."";
	mysql_query($query);
	} else {
	$query="insert into attendance (uid,day,att) values (".$_SESSION['uid'].",".$timestamp.",".$date->tosec($_POST['value']).") ";
	mysql_query($query);
	}
 

echo $_POST['value'];


//echo $_POST['month']."/".$_POST['id']."/".$_POST['year']."-00:00:00";
//echo $queryX;


}
